{template 'common/header'}
<script type="text/javascript" src="https://de.mii.red/web/resource/js/lib/jquery-1.11.1.min.js"></script>
<div class="panel we7-panel ng-scope" >
	<div class="panel-heading">参数设置</div>
	<div class="panel-body we7-padding">
		<div class="form-horizontal">
		<div class="form-group">
			<label class="col-sm-2 control-label">腾讯地图秘钥(KEY)</label>
			<div class="col-sm-8">
				<input type="text" class="form-control" id="tenkey" name="tenkey" value="{$setting['tenkey']}">
			</div>
	 	</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">公众平台AppId</label>
			<div class="col-sm-8">
				<input type="text" class="form-control" id="appid" name="appid" value="{$setting['appid']}">
			</div>
	 	</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">公众平台AppSecret</label>
			<div class="col-sm-8">	
				<input type="text" class="form-control" id="appsecret" name="appsecret" value="{$setting['appsecret']}">
			</div>
	 	</div>

		<div class="form-group">
          <label class="col-sm-2 control-label">是否开启短信通知</label>
          <div class="col-sm-8">
          <label class="radio-inline">
            <input type="radio" name="sms_note" id="sms_note" value="0" {if $setting['sms_note']=='0'}checked="checked"{else}{/if}> 关闭</label>
            <label class="radio-inline">
            <input type="radio" name="sms_note" id="sms_note" value="1" {if $setting['sms_note']=='1'}checked="checked"{else}{/if}> 开启
          </label>
          <span class="help-block">&nbsp;&nbsp;开启后，请配置阿里大于/阿里云短信。</span>
          </div>            
       </div>  

		<div class="form-group">
		<label class="col-sm-2 control-label">短信签名</label>
    	<div class="col-sm-8">
	      	<input class="form-control required" type="text" id="signName" name="signName" placeholder="配置短信签名" value="{$sms_config['signName']}">
	      	 <span class="help-block">&nbsp;&nbsp;配置短信签名</span>
		</div>			
		</div> 

		<div class="form-group">
		<label class="col-sm-2 control-label">App Key</label>
    	<div class="col-sm-8">
      	<input class="form-control required" type="text" id="alikey" name="alikey" placeholder="App Key" value="{$sms_config['alikey']}">
      	 <span class="help-block">&nbsp;&nbsp;阿里大于Key/阿里云通信accessKeyId</span>
		</div>			
		</div> 

		<div class="form-group">
		<label class="col-sm-2 control-label">App Secret</label>
	    	<div class="col-sm-8">
	      	<input class="form-control required" type="text" id="alisecret" name="alisecret" placeholder="App Secret" value="{$sms_config['alisecret']}">
	      	 <span class="help-block">&nbsp;&nbsp;阿里大于 App Secret/阿里云通信accessKeySecret</span>
			</div>			
		</div>

		<div class="form-group">
		<label class="col-sm-2 control-label">短信模板ID</label>
    	<div class="col-sm-8">
      	<input class="form-control required" type="text" id="template_id" name="template_id" placeholder="短信模板ID" value="{$sms_config['template_id']}">
      	 <span class="help-block">&nbsp;&nbsp;阿里大于 短信通知模板ID  模板内容 【顾客:${name},预约服务:${sname},预约时间;${time},手机号:${phone},请您及时处理。】解析 ${name}:顾客姓名 ${sname}服务名称 ${time}预约时间  ${phone}手机号 </span>
		</div>			
		</div>	 				 	
		<button type="button" id="save_info" class="btn btn-info" style="display: block; margin-left: auto;margin-right: auto;">提交保存</button>	 	
	 	</div>		
	</div>
</div>
<style type="text/css">.right-content{padding: 0;}</style>
<link rel="stylesheet" href="{MODULE_URL}public/css/Toast.css">
<script src="{MODULE_URL}public/js/Toast.js"></script>  
<script>
	$("#save_info").on(
        "click",function(){
        	var tenkey = $.trim($("#tenkey").val());
        	var appid = $.trim($("#appid").val());
        	var appsecret = $.trim($("#appsecret").val());
        	var sms_note =$.trim($("input[name='sms_note']:checked").val());
        	var signName = $.trim($("#signName").val());
        	var alikey = $.trim($("#alikey").val());
        	var alisecret = $.trim($("#alisecret").val());
        	var template_id = $.trim($("#template_id").val());       	
        	if(sms_note==1){
        		if(signName==''){
					mqToast({type:1,context:'请填写短信签名'});
					return false;        			
        		}
        		if(alikey==''){
					mqToast({type:1,context:'请填写阿里大于 App key'});
					return false;          			
        		}
        		if(alisecret==''){
					mqToast({type:1,context:'请填写阿里大于 App Secret'});
					return false;        			
        		}
        		if(template_id==''){
					mqToast({type:1,context:'请填写阿里大于 短信通知模板ID'});
					return false;        			
        		}

        	}
        	if(tenkey==''){
        		mqToast({type:1,context: '请填写腾讯地图KEY'});
        		return false;
        	}
	        	$.ajax({
					url:"{php echo $this->createWebUrl('save_setting');}&version_id="+"{$_GPC['version_id']}",
					data:{tenkey:tenkey,appid:appid,appsecret:appsecret,sms_note:sms_note,signName:signName,alikey:alikey,alisecret:alisecret,template_id:template_id},
					dataType:"json",
					type:"post",
					success:function(res){
						if(res.status==1){
							mqToast({type:1,context:res.msg});
							return false;
						}else{
							mqToast({type:2,context:res.msg});
							return false;
						}
					}
				});		   		
        	});
	</script>	
{template 'common/footer'}